All Questions
4 questions
2votes
1answer
118views
Is it a good software engineering practice to store libraries as attributes of objects?
Suppose I initialize a library, say, in python object - #filename: file_A import file_ class A(): def __init__(self): self.pd = file_.pd self.np = file_.np And suppose the ...
2votes
2answers
4kviews
Module with globals or Class with attributes?
Currently I'm working with a lot of modules where the original developers used global variables to control states and to exchange important information between functions, like so: STATE_VAR = 0 def ...
0votes
1answer
847views
Should I put the parameters in constructor or in method? (Python 3)
I have the following code: def __init__(self, vocable_file_path, xsd_file_path, word_list_file_path): self.vocable_file_path = vocable_file_path self.xsd_file_path = xsd_file_path self....
13votes
3answers
27kviews
Is it a better practice pre-initialize attributes in a class, or to add them along the way?
I'm sorry if this is a ABSOLUTELY sophomoric question, but I'm curious what the best practices are out there, and I can't seem to find a good answer on Google. In Python, I usually use an empty class ...